package cn.pink.gamesrv.account;

import cn.pink.core.CallPoint;
import cn.pink.core.NodeType;
import cn.pink.core.Port;
import cn.pink.core.Service;
import cn.pink.core.gen.proxy.DistrClass;
import cn.pink.core.gen.proxy.DistrMethod;
import cn.pink.gamesrv.RPCProxy;
import cn.pink.gamesrv.msg.AccountMsgRoute;

/**
 * 账号服务
 * @Author: pink
 * @Date: 2022/6/27 20:19
 */
@DistrClass(nodeType = NodeType.GAME)
public class AccountService extends Service {
    /** 消息路由类 */
    private static AccountMsgRoute msgRoute = new AccountMsgRoute();

    public AccountService(Port port) {
        super(port);
    }

    @Override
    public Object getId() {
        return RPCProxy.AccountServiceProxy.DIST_NAME;
    }

    @DistrMethod
    public void defaultHandler(String sessionId, byte[] msgBuf) {
        CallPoint sessionPoint = new CallPoint();
        sessionPoint.nodeId = port.getCallFromNodeId();
        sessionPoint.portId = port.getCallFromPortId();
        sessionPoint.servId = sessionId;

        msgRoute.handle(msgBuf, "sessionPoint", sessionPoint, "serv", this);
    }
}
